import { baseRequestClient, requestClient } from '#/api/request';

export namespace Package {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    packageId: number;
    parentId: number;
    ancestors: string;
    packageCode: string;
    barcodeId: null | number;
    barcodeContent: null | string;
    barcodeUrl: null | string;
    packageDate: Date;
    soCode: null | string;
    invoiceCode: null;
    clientId: number;
    clientCode: string;
    clientName: string;
    clientNick: null;
    packageLength: null | number;
    packageWidth: null | number;
    packageHeight: null | number;
    sizeUnit: null | string;
    netWeight: null;
    crossWeight: null;
    weightUnit: null;
    inspector: null;
    inspectorName: null;
    enableFlag: string;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getPackageTableList = (params: Package.GetListParams) =>
  requestClient.get<Package.GetListReturn>('/mes/wm/package/list', {
    params,
  });
// 增加装箱单
export const addPackage = (data: Package.Row) =>
  requestClient.post<Package.GetListReturn>('/mes/wm/package', data);

// 删除装箱单
export const deletePackage = (id: string) =>
  requestClient.delete<Package.GetListReturn>(`/mes/wm/package/${id}`);

// 修改装箱单
export const updatePackage = (data: Package.Row) =>
  requestClient.put<Package.GetListReturn>('/mes/wm/package', data);

export const getPackageCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/PACKAGE_CODE');
